#ifndef __ES1642_HAL_H
#define __ES1642_HAL_H
#include "project_config.h"

#if ES1642_EN
#include <stdint.h>
#include <stdbool.h>
#define ES_DEBUG	1
#if ES_DEBUG
#include "bsp_log.h"
#define ES_DEBUG_LOG	log_d
#else
#define ES_DEBUG_LOG
#endif

#define ES_FIFO_SIZE	512

typedef enum
{
	EV_RPLY_OK			= 1<<0,
	EV_RPLY_ERR			= 1<<1,
    EV_RPLY_TIMEOUT     = 1<<2,
} eESEventType;


uint32_t Es1642InitUart(uint32_t baud);
void Es1642WriteByte( uint8_t data );
void Es1642WriteBuffer( uint8_t *buffer, uint16_t size );
int32_t Es1642ReadByte( uint8_t *pdata );
int32_t Es1642ReadBuffer( uint8_t *buffer, uint32_t *size );


void vESPortSemaphoreInit( void );
bool xESSendTake( uint32_t timeout );
void vESSendGive( void );

bool xESPortEventInit( void );
bool xESPortEventPost( eESEventType eEvent );
bool xESPortEventGet( eESEventType *eEvent );

bool xESPortSendTimerInit(uint16_t timeout_ms);
void vESPortSendTimerStart(uint16_t timeout_ms);
void vESPortSendTimerStop(void);


void *ESPortMalloc(uint16_t size);
void ESPortFree( void *pv );

#endif	/* ES1642_EN */

#endif	//	__ES1642_HAL_H
